package com.wb.designmode.observable;

import java.util.ArrayList;
import java.util.List;

public class User implements ObServable {

    private List<Observer> observersList;
    private String name;

    public User() {
        observersList = new ArrayList<>();
    }

    public User(String name) {
        observersList = new ArrayList<>();
        this.name = name;
    }

    @Override
    public void addObserver(Observer observer) {
        observersList.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observersList.remove(observer);
    }

    @Override
    public void notifyObservers(String message) {
        observersList.forEach(obj -> {
            obj.update(name, message);
        });
    }
}
